package com.qg.controller;

import com.qg.dto.ReturnResult;
import com.qg.pojo.QgGoods;
import com.qg.service.LocalGoodsService;
import com.qg.utils.EmptyUtils;
import com.qg.vo.QgGoodsVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/goods")
public class GoodsController {
    @Resource
    private LocalGoodsService localGoodsService;

    @RequestMapping(value = "/getQgGoodsById",method = RequestMethod.POST)
    @ResponseBody
    public QgGoodsVo getQgGoodsById(String id) throws Exception{
        QgGoodsVo qgGoodsVo=localGoodsService.getQgGoodsById(id);
        if (EmptyUtils.isEmpty(qgGoodsVo)){
            return null;
        }
        return qgGoodsVo;
    }

    @RequestMapping(value = "/getGoods",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult getGoods(String token,String goodsId)throws Exception{
        return localGoodsService.sendGoodsMessage(token,goodsId);
    }
}
